//
//  CMDevice.swift
//  CMKit
//
//  Created by travel on 2016/12/15.
//  Copyright © 2016年 covermedia. All rights reserved.
//

import Foundation


public class CMDevice {
    private lazy var deviceString: String = self.getDeviceString()
    
    private static let shared = CMDevice()
    
    private func getDeviceString() -> String {
        var systemInfo = utsname()
        uname(&systemInfo)
        
        let versionCode = String(validatingUTF8: NSString(bytes: &systemInfo.machine, length: Int(_SYS_NAMELEN), encoding: String.Encoding.ascii.rawValue)!.utf8String!)
        
        return versionCode ??  "Unknown"
    }
    
    private var isSimulator: Bool {
        #if arch(i386) || arch(x86_64)
            return true
        #else
            return false
        #endif
    }
    
    /// 设备名称
    public class var deviceString: String {
        return shared.deviceString
    }
    
    /// 是否为模拟器
    public class var isSimulator: Bool {
        return shared.isSimulator
    }
}
